﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetStaffInStep_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetStaffInStep_V2];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetStaffInStep_V2]
    @FlowID int,
    @StepID int
AS
BEGIN
SET NOCOUNT ON;

-- 获得绑定角色里成员
SELECT
        S.*,
        P.Position_ID,
        P.Position_name
    FROM
        dbo.UDS_Staff S
        INNER JOIN dbo.UDS_Staff_In_Position SIP ON S.Staff_ID = SIP.Staff_ID
        INNER JOIN dbo.UDS_Position P ON SIP.Position_ID = P.Position_ID
    WHERE
        S.Staff_ID IN
        (
            SELECT staff_id 
                FROM 
                    dbo.v_uds_flow_staff_in_step
                WHERE
                    flow_id = @flowid 
                    and step_id = @stepid
        )

END
GO
